package service;

import dao.BlogDao;
import dao.BlogDaoImpl;
import util.DatabaseUtil;

import java.sql.Connection;
import java.sql.SQLException;

public class BlogServiceImpl implements BlogService{

    Connection conn =null;// DatabaseUtil.getConnection();
    BlogDao blogDao =null;//new BlogDaoImpl(conn);

    public BlogServiceImpl() {
        try {
            conn = DatabaseUtil.getConnection();
            blogDao =new BlogDaoImpl(conn);
           /* new CommentDaoImpl(conn);
            new LikesDaoImpl(conn);
            new FollowDaoImpl(conn);*/

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    @Override
    public int getBlogCount() throws SQLException {
        try {
            return blogDao.getBlogCount();
        } finally {
            DatabaseUtil.close(conn,null,null);
        }

    }
}
